package com.happiness.system.controller;


import com.happiness.base.annotation.WebResult;
import com.happiness.system.TGood;
import com.happiness.system.mapper.TGoodMapper;
import com.happiness.system.service.TestInfoService;
import io.seata.spring.annotation.GlobalTransactional;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/api/v1/user")
@Api("用户层")
public class SysUserController {

    @Resource
    private TestInfoService testInfoService;

    @Resource
    private TGoodMapper tGoodMapper;

    @WebResult
    @GetMapping("get")
    @GlobalTransactional
    @Transactional
    public List<String> getTestInfo(HttpServletRequest request) {
        TGood tGood = new TGood();
        tGood.setAmount("123456");
        tGoodMapper.insert(tGood);
        List<String> strings = Arrays.asList(new String[]{testInfoService.get()});
        return strings;
    }

}
